//
//  QrViewController.swift
//  iPhone
//
//  Created by Toj on 6/13/22.
//

import UIKit

class QrViewController: STBaseViewController {
    override var pagePath: String {
        return  "startimes://wallet"
    }
    
    var timer: Timer?
    private lazy var qrImageView: UIImageView = UIImageView()
    override func viewDidLoad() {
        super.viewDidLoad()
        
        tt_isNavigationBarHidden = true
        
        view.addSubview(qrImageView)
        qrImageView.snp.makeConstraints { make in
            make.height.width.equalTo(200)
            make.center.equalTo(view)
        }
        view.layoutIfNeeded()
        
        let barCodeName = "SN00000000001"
        var size = CGSize.zero
        
        size = qrImageView.frame.size
        STBarCode.shared.qrCode(content: barCodeName, size: size) { image in
            self.qrImageView.image = image
        }
        
        // 外部调用target直接传self就行
        self.timer = Timer.st_scheduledTimer(timeInterval: 1, target: self, selector: #selector(autoScroll), userInfo: nil, repeats: true)
    }
    
    var index = 1
    
    @objc func autoScroll() {
        print(index)
        index += 1
    }
}

extension QrViewController {
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        print("-->shantao: 2 class:\(st_className), func: \(#function)")
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        print("-->shantao: 2 class:\(st_className), func: \(#function)")
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        
        print("-->shantao: 2 class:\(st_className), func: \(#function)")
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        
        print("-->shantao: 2 class:\(st_className), func: \(#function)")
    }
}
